home *** CD-ROM | disk | FTP | other *** search
- /*
- caps attached to a curve.c
-
- This file contains the calls to create a "thick" curve and attach a cap to each end of the
- curve.
-
- NOTES:
- • This file requires the following files to run correctly:
- "graphics shell.c", "ColorLibrary.c", "GraphicsDebugLibrary.c",
- "ShapeLibrary.c", "TransformLibrary.c".
-
- • This file prints the "best" in landscape mode.
-
-
- Change History:
-
- 4/96 bob Updated #includes to support changed GX Library names.
- Updated the note regarding the files needed to run, and copyright date.
-
- ©1992 - 1996 Apple Computer, Inc.
- All rights reserved.
- */
-
-
- #include <events.h>
- #include <windows.h>
-
- #include <GXErrors.h>
- #include "GraphicsLibraries.h"
- #include <GXEnvironment.h>
- #include "graphics shell.h"
-
- //
- // Set up the title and size of the window
- //
- Str255 gWindowTitle = "\p Caps Attached To a Curve";
- Rect gWindowQDRect = {50, 20, 275, 350};
-
- //
- // gGraphicsHeapSize sets the size of the graphics gxHeap created by calling the GXNewGraphicsClient routine
- // in main () within graphics shell.c. You can determine the amount of graphics gxHeap required by using GraphicsBug.
- // With gGraphicsHeapSize set to 10k, I had 3 free blocks left in the graphics gxHeap. Sounds good to me.
- //
- long gGraphicsHeapSize = 10;
-
- gxShape gShape;
- short gClickNumber;
-
-
-
- /*------ DoInitialization ---------------------------------------------------------------------------------*/
-
- void DoInitialization(gWindow)
- WindowPtr gWindow;
- {
- gxCurve curveGeometry = {ff(25), ff(125), ff(100), 0, ff(225), ff(125)};
- gxShape arrowHead, arrowTail;
- long arrowHeadPolygonGeometry[] = { 4, // Number of points,
- -ff(2)-fixed1/2, 0,
- 0, fixed1,
- fixed1 + fixed1/2, 0,
- 0, -fixed1};
-
- long arrowTailPolygonGeometry[] = { 5, // Number of points,
- -fixed1, 0,
- 0, fixed1,
- ff(2), fixed1,
- ff(2), -fixed1,
- 0, -fixed1};
- gxCapRecord theCapRecord;
-
- InitCommonColors();
-
- gShape = GXNewCurve (&curveGeometry);
-
- //
- // Create the cap shapes
- //
- arrowHead = NewPolygon((gxPolygon *) &arrowHeadPolygonGeometry);
- arrowTail = NewPolygon((gxPolygon *) &arrowTailPolygonGeometry);
-
- //
- // We needed to reverse the direction of the contour to prevent a hole from being drawn
- // were the arrowHead or arrowTail capped the curve. This was an issue because the
- // shape fill of the curve is openFrame and the arrowHead and arrowTail are evenOdd.
- //
- GXReverseShape(arrowHead, 1);
- GXReverseShape(arrowTail, 1);
-
- //
- // Add the appropriate shape for start cap and end cap
- //
- theCapRecord.startCap = arrowHead;
- theCapRecord.endCap = arrowTail;
- theCapRecord.attributes = gxNoAttributes;
-
- //
- // Add the cap record to our "gShape"
- //
- GXSetShapeCap(gShape, &theCapRecord);
-
- //
- // We do no need the cap shapes because they have been copied into the cap record which is
- // now part of the style used by "gShape".
- //
- GXDisposeShape(arrowHead);
- GXDisposeShape(arrowTail);
-
- GXSetShapePen(gShape, ff(15));
- SetShapeCommonColor(gShape, red);
- GXMoveShape (gShape, ff(35), 0);
-
- gClickNumber = 1;
- }
-
- /*------ DoClick ---------------------------------------------------------------------------------------*/
-
- void DoClick( orgMouseLoc, theWindow )
- gxPoint orgMouseLoc;
- WindowPtr theWindow;
- {
- }
-
-
-
-
- /*------ DoDraw ---------------------------------------------------------------------------------------*/
-
- void DoDraw(gWindow)
- WindowPtr gWindow;
- {
- GXDrawShape (gShape);
- }
-
-
- /*------ DoDispose -------------------------------------------------------------------------------------*/
-
- void DoDispose(gWindow)
- WindowPtr gWindow;
- {
- /**
- You should always dispose of your GX graphics objects before tossing your window. Why? It's generally good
- form and this approach guarantees that everything is disposed. If you had not disposed of everything, the
- call to DisposeWindow should dispose of the objects. If you are running the debugging version of the
- SecretGraphics init with notices set, you will receive a notice that you had not disposed of everything. You
- can turn notices on in this file by setting gDebugging = TRUE (above).
- **/
- GXDisposeShape(gShape);
- GXDisposeShape(gWindowBoundsShape);
- DisposeCommonColors();
- DisposeWindow(gWindow);
- }
-
-
-
- /*------ DoIdle ----------------------------------------------------------------------------------------*/
-
- void DoIdle(gWindow)
- WindowPtr gWindow;
- {
- }
-